

package com.hazelcast.json.internal;

import com.hazelcast.nio.serialization.IdentifiedDataSerializable;

/**
 * A node that describes either a JsonValue
 */
public abstract class JsonSchemaNode implements IdentifiedDataSerializable {

    private JsonSchemaStructNode parent;

    protected JsonSchemaNode() {
        // no-op
    }

    /**
     * Creates a schema node with given parent
     *
     * @param parent may be null for top element
     */
    protected JsonSchemaNode(JsonSchemaStructNode parent) {
        this.parent = parent;
    }


    /**
     * Returns the parent.
     *
     * @return the parent
     */
    public JsonSchemaStructNode getParent() {
        return parent;
    }

    /**
     * Sets the parent of this node. May be null for top element.
     */
    public void setParent(JsonSchemaStructNode parent) {
        this.parent = parent;
    }

    /**
     * Returns whether this node represents a scalar value.
     *
     * @return false if this is an array or object, true otherwise
     */
    public boolean isTerminal() {
        return false;
    }
}
